package com.example.persistence;

import android.graphics.Bitmap;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.example.R;
import com.example.module.flipper.FlipSwicher;
import com.example.util.ImageUtil;

public class FlipActivity extends BaseActivity {
	private ViewGroup container;
	
	@Override
	protected void onStart() {
		container = ((ViewGroup) findViewById(R.id.container));
		
		if (FlipSwicher.getInstance().getFlipAction() != FlipSwicher.FlipAction.DONE) {
			addContentView(FlipSwicher.getInstance().createPrevView(this),
					new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, Gravity.TOP));
			
			FlipSwicher.getInstance().setNextView(container);
			FlipSwicher.getInstance().rotateView(getWindowManager());
		}
		
		super.onStart();
	}
	
	public ViewGroup getContainer() {
		return container;
	}

	public void setContainer(ViewGroup container) {
		this.container = container;
	}
	
	public Bitmap getContainerBitmap() {
		return ImageUtil.getBitmapFromView(container);
	}
}
